import request from '@/utils/request'
import scope from './scope'
const apiPrefix = `${process.env.VUE_APP_BASE_API}/${scope}/permission/`

// 权限管理
export const getPermissionList = (params, config = {}) => {
    return request.get(apiPrefix + 'list', { params: params, ...config })
}
export const deletePermission = (params, config = {}) => {
    return request.delete(apiPrefix + params.id, { params: params, ...config })
}
export const getPermissions = (params, config = {}) => {
    return request.get(apiPrefix + 'permission-list', { params: params, ...config })
}
export const getPermissionIds = (params, config = {}) => {
    return request.get(apiPrefix + params.roleId + '/role-permission-list', { params: params, ...config })
}
export const GetTenantPermissionIds = (params, config = {}) => {
    return request.get(apiPrefix + params.tenantId + '/tenant-permission-list', { params: params, ...config })
}
export const addRolePermission = (params, config = {}) => {
    return request.post(apiPrefix + 'assign', params, config)
}
export const saveTenantPermissions = (params, config = {}) => {
    return request.post(apiPrefix + 'save-tenant-permissions', params, config)
}

export const addGroup = (params, config = {}) => {
    return request.post(apiPrefix + 'group', params, config)
}
export const addMenu = (params, config = {}) => {
    return request.post(apiPrefix + 'menu', params, config)
}
export const addApi = (params, config = {}) => {
    return request.post(apiPrefix + 'api', params, config)
}
export const addDot = (params, config = {}) => {
    return request.post(apiPrefix + 'dot', params, config)
}

export const updateGroup = (params, config = {}) => {
    return request.put(apiPrefix + 'group', params, config)
}
export const updateMenu = (params, config = {}) => {
    return request.put(apiPrefix + 'menu', params, config)
}
export const updateApi = (params, config = {}) => {
    return request.put(apiPrefix + 'api', params, config)
}
export const updateDot = (params, config = {}) => {
    return request.put(apiPrefix + 'dot', params, config)
}

export const getGroup = (params, config = {}) => {
    return request.get(apiPrefix + params.id + '/group', { params: params, ...config })
}
export const getMenu = (params, config = {}) => {
    return request.get(apiPrefix + params.id + '/menu', { params: params, ...config })
}
export const getApi = (params, config = {}) => {
    return request.get(apiPrefix + params.id + '/api', { params: params, ...config })
}
export const getDot = (params, config = {}) => {
    return request.get(apiPrefix + params.id + '/dot', { params: params, ...config })
}